/* nav各种事件 */
var navHandler = (function() {
    var navOpen = document.querySelector(".header i");
    var navClose = document.querySelector(".nav i");
    var searchOpen = document.querySelector(".header b");
    var searchClose = document.querySelector(".search i");
    var nav = document.querySelector(".nav");
    var search = document.querySelector(".search");
    var navWidth = 3.76;
    var id = 0;
    

    /* 设置nav和search的高 */
    nav.firstElementChild.style.height = window.innerHeight + "px";
    search.style.height = window.innerHeight + "px";
    
    navOpen.addEventListener("click", function() {
        if(id)return;
        nav.style.display = "block";
        document.body.style.overflow = "hidden";
        id = setTimeout(function() {
            nav.style.opacity = "1";
            nav.style.left = "0rem";
            clearTimeout(id);
            id = 0
        }, 0)
    });

    navClose.addEventListener("click", function() {
        if(id)return;
        nav.style.opacity = "0";
        nav.style.left = "-3.76rem";
        id = setTimeout(function() {
            document.body.style.overflow = "";
            nav.style.display = "none";
            clearTimeout(id);
            id = 0
        }, 650)
    });

    searchOpen.addEventListener("click", function() {
        if(id)return;
        search.style.display = "block";
        document.body.style.overflow = "hidden";
        id = setTimeout(function() {
            search.style.opacity = "1";
            clearTimeout(id);
            id = 0
        }, 0)
    });

    searchClose.addEventListener("click", function() {
        if(id)return;
        search.style.opacity = "0";
        id = setTimeout(function() {
            document.body.style.overflow = "";
            search.style.display = "none";
            clearTimeout(id);
            id = 0
        }, 650)
    });

    

})();



